﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Web;
using SHJunketingBLL;
using SHJunketingModel;
using System.Collections.Generic;
public partial class Admin_UserManagement_AddUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            IList<C_YuyueType> list = C_YuyueTypeManage.GetAllC_YuyueType();

            this.ddlYuyuefenlei.Items.Clear();
            //this.ddlYuyuefenlei.Items.Add(new ListItem("请选择所属类别...", ""));

            foreach (C_YuyueType dr in list)
            {

                this.ddlYuyuefenlei.Items.Add(new ListItem(dr.Name, dr.ID.ToString()));
            }
            ddlYuyuefenlei.SelectedIndex = 0;

            this.lblTime.Text = list[0].Starttime + "/" + list[0].Endtime;
        }
    }
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        //查找用户时候存在
        if (C_UserLoginManager.GetUserIds(txtName.Text.Trim()) != null)
        {
            Web.CommFun.Show_Msg("用户已经存在！");
        }
        else
        {
           
            //添加数据到users表
            string sql = "insert into users values('" + txtName.Text.Trim() + "','666666','" + txtUserName.Text.Trim() + "','" + rdoSex.SelectedValue + "','" + txtDepartment.Text.Trim() + "','" + txtCostCenters.Text.Trim() + "','" + txtUserIDCard.Text.Trim() + "','" + txtUserAge.Text.Trim()
                + "','" + rdoMarriage.SelectedValue + "','" + txtPhoneNumber.Text.Trim() + "','" + txtTelephone.Text.Trim() + "','" + txtAddress.Text.Trim() + "','" + txtUserEmai.Text.Trim() + "','" + txtArea.Text.Trim() + "',0,'" + rdoLang.SelectedValue + "','" + rdologinType.SelectedValue + "','" + rdoVIP.SelectedValue + "','" + rdoUser.SelectedValue + "','" + this.txtRemark.Text + "','" + ddlYuyuefenlei.SelectedValue + "')";

            sql += " ; SELECT @@IDENTITY";

            int userid = DBHelper.GetScalar(sql);
            if(userid>0)
                Web.CommFun.Show_Msg("添加成功！", "userManage.aspx");
        }
    }

    protected void ddlYuyuefenlei_SelectedIndexChanged(object sender, EventArgs e)
    {

        if (ddlYuyuefenlei.SelectedValue == "")
        {
            return;
        }
        C_YuyueType type = C_YuyueTypeManage.GetYuyueTypeByID(int.Parse(ddlYuyuefenlei.SelectedValue));
        this.lblTime.Text = type.Starttime + "/" + type.Endtime;
    }
}
